#ifndef EJANIMATION_H
#define EJANIMATION_H
#include <QPoint>
#include <QPixmap>
#include <QVector>
#include <QImage>
#include <QPainter>
#include <functional>

struct AnimationEvent
{

};

struct AnimationFrame
{
    QPoint            off;
    QPixmap           pixmap;
    AnimationFrame(const QPixmap &pix, const QPoint &point = QPoint()):pixmap(pix), off(point){}
};


typedef std::function<int(AnimationEvent *)> AnimationCallBack;

class EJAnimation
{
public:
    void addFrame(AnimationFrame *frame){m_frames.push_back(frame);}
    void setFrames(QVector<AnimationFrame*> &frames){m_frames = frames;}
    void setFps(int fps){m_fps = fps;}
    void setCallback(AnimationCallBack callback){m_callback = callback;}

    int  getFrameCount(){return m_frames.size();}

    int  getFPS(){return m_fps;}

    AnimationFrame *getFrame(int index){return m_frames[index % m_frames.size()];}

private:
    QVector<AnimationFrame*> m_frames;
    AnimationCallBack       m_callback;
    int                     m_callbackIndex;
    int                     m_fps;
};

#endif // EJANIMATION_H
